
/*

DEPENDENCIES:
-------------
Gimme.Effects
ext.get_scroll_pos
ext.get_absolute_pos
-------------


IN THIS FILE:
-------------
ext.scroll_to
-------------

*/

Gimme.ext.scroll_to = function(duration, guid, callback, easing)
{
	var scrollPos = Gimme.Screen.get_scroll_pos();
	var elemPos = Gimme(this[0]).get_absolute_pos();
	
	var round = Math.round;
	var ease = Gimme.Effects.Easing.Exponential.ease_out;
	
	var sb = Gimme.Effects.Storyboard.create
	(
		// items to animate
		[ window ],
		
		//from
		{
			scrollX: scrollPos.x,
			scrollY: scrollPos.y
		},
		
		//to
		{
			scrollX: elemPos.x,
			scrollY: elemPos.y
		},
		
		// animate function
		function(win, props)
		{
			win.scrollTo(round(props.scrollX), round(props.scrollY));
		},
		
		//duration
		duration,
		
		//guid
		guid,
		
		//callback,
		callback,
		
		//easing
		easing || function(t)
		{
			return ease(t, 4);
		}
	);
	
	sb.begin();
	return this;
};
//[AltSyntax]Gimme.ext.scrollTo = Gimme.ext.scroll_to;